/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on Jul 24, 2010, 9:46:06 PM
 */
package com.oi.eksekutif.main;

import com.oi.eksekutif.provider.ApplicationContextProvider;
import com.oi.eksekutif.ui.form.JenisTagihanPanel;
import com.oi.eksekutif.ui.form.MerkMobilPanel;
import com.oi.eksekutif.ui.form.MobilPanel;
import com.oi.eksekutif.ui.form.PengemudiPanel;
import com.oi.eksekutif.ui.form.PosisiPanel;
import com.oi.eksekutif.ui.form.SuratJalanPanel;
import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
import java.awt.CardLayout;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.springframework.context.ApplicationContext;

/**
 *
 * @author jasoet
 */
public class MainFrame extends javax.swing.JFrame {

    /** Creates new form MainFrame */
    public MainFrame() {
        ApplicationContext applicationContext = ApplicationContextProvider.getInstance().getApplicationContext();
        initComponents();
        PengemudiPanel pengemudiPanel = applicationContext.getBean("pengemudiPanel", PengemudiPanel.class);
        centerPanel.add(pengemudiPanel, "pengemudiPanel");
        JenisTagihanPanel jenisTagihanPanel = applicationContext.getBean("jenisTagihanPanel", JenisTagihanPanel.class);
        centerPanel.add(jenisTagihanPanel, "jenisTagihanPanel");
        MerkMobilPanel merkMobilPanel = applicationContext.getBean("merkMobilPanel", MerkMobilPanel.class);
        centerPanel.add(merkMobilPanel, "merkMobilPanel");
        PosisiPanel posisiPanel = applicationContext.getBean("posisiPanel", PosisiPanel.class);
        centerPanel.add(posisiPanel, "posisiPanel");
         MobilPanel mobilPanel = applicationContext.getBean("mobilPanel", MobilPanel.class);
        centerPanel.add(mobilPanel, "mobilPanel");
         SuratJalanPanel suratJalanPanel = applicationContext.getBean("suratJalanPanel", SuratJalanPanel.class);
        centerPanel.add(suratJalanPanel, "suratJalanPanel");

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        homeButton = new javax.swing.JButton();
        pengemudiButton = new javax.swing.JButton();
        jenisTagihanButton = new javax.swing.JButton();
        merkMobilButton = new javax.swing.JButton();
        posisiButton = new javax.swing.JButton();
        mobilButton = new javax.swing.JButton();
        suratJalanButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        centerPanel = new javax.swing.JPanel();
        homePanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Eksekutif Taxi");
        setLocationByPlatform(true);

        jToolBar1.setRollover(true);

        homeButton.setText("Home");
        homeButton.setFocusable(false);
        homeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        homeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        homeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(homeButton);

        pengemudiButton.setText("Pengemudi");
        pengemudiButton.setFocusable(false);
        pengemudiButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        pengemudiButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        pengemudiButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pengemudiButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(pengemudiButton);

        jenisTagihanButton.setText("Jenis Tagihan");
        jenisTagihanButton.setFocusable(false);
        jenisTagihanButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jenisTagihanButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jenisTagihanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jenisTagihanButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(jenisTagihanButton);

        merkMobilButton.setText("Merk Mobil");
        merkMobilButton.setFocusable(false);
        merkMobilButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        merkMobilButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        merkMobilButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                merkMobilButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(merkMobilButton);

        posisiButton.setText("Posisi");
        posisiButton.setFocusable(false);
        posisiButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        posisiButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        posisiButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                posisiButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(posisiButton);

        mobilButton.setText("Mobil");
        mobilButton.setFocusable(false);
        mobilButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        mobilButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        mobilButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mobilButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(mobilButton);

        suratJalanButton.setText("Surat Jalan");
        suratJalanButton.setFocusable(false);
        suratJalanButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        suratJalanButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        suratJalanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                suratJalanButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(suratJalanButton);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);

        centerPanel.setLayout(new java.awt.CardLayout());

        homePanel.setLayout(new java.awt.BorderLayout());

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/oi/eksekutif/main/jasoet.jpg"))); // NOI18N
        homePanel.add(jLabel1, java.awt.BorderLayout.CENTER);

        centerPanel.add(homePanel, "cardSatu");

        jScrollPane1.setViewportView(centerPanel);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void pengemudiButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pengemudiButtonActionPerformed
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "pengemudiPanel");
    }//GEN-LAST:event_pengemudiButtonActionPerformed

    private void homeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeButtonActionPerformed
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "cardSatu");
    }//GEN-LAST:event_homeButtonActionPerformed

    private void jenisTagihanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jenisTagihanButtonActionPerformed
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "jenisTagihanPanel");
    }//GEN-LAST:event_jenisTagihanButtonActionPerformed

    private void merkMobilButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_merkMobilButtonActionPerformed
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "merkMobilPanel");
    }//GEN-LAST:event_merkMobilButtonActionPerformed

    private void posisiButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_posisiButtonActionPerformed
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "posisiPanel");
    }//GEN-LAST:event_posisiButtonActionPerformed

    private void mobilButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mobilButtonActionPerformed
         CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "mobilPanel");
    }//GEN-LAST:event_mobilButtonActionPerformed

    private void suratJalanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_suratJalanButtonActionPerformed
        // TODO add your handling code here:
        CardLayout cl = (CardLayout) centerPanel.getLayout();
        cl.show(centerPanel, "suratJalanPanel");
    }//GEN-LAST:event_suratJalanButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
            java.awt.EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    new MainFrame().setVisible(true);
                }
            });
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }


    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel centerPanel;
    private javax.swing.JButton homeButton;
    private javax.swing.JPanel homePanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton jenisTagihanButton;
    private javax.swing.JButton merkMobilButton;
    private javax.swing.JButton mobilButton;
    private javax.swing.JButton pengemudiButton;
    private javax.swing.JButton posisiButton;
    private javax.swing.JButton suratJalanButton;
    // End of variables declaration//GEN-END:variables
}
